package 无重复字符的最长子串;

class Solution {
    public int lengthOfLongestSubstring(String s) {
        int[] hash = new int[128];
        int left = 0;
        int right = 0;
        int len = 0;
        int n = s.length();
        while(right < n){
            hash[s.charAt(right)]++;
            while(left <= right && hash[s.charAt(right)] > 1){
                hash[s.charAt(left++)]--;
            }
            len = Math.max(len,right - left + 1);
            right++;
        }
        return len;
    }
}